package com.lsl.test1;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author lishuailong
 * @create 2020-07-06 17:42
 */
public class testE {


    public static void main(String[] args) {


        Callable callable = new Callable() {
            @Override
            public Object call() throws Exception {
                int i = 30;
                while (i > 0) {
                    System.out.println(i--);
                }
                return "666";
            }
        };
        FutureTask futureTask = new FutureTask(callable);

        new Thread(futureTask).start();

        try {
            System.out.println(777);
            Object o = futureTask.get();
            System.out.println("o = " + o);
            System.out.println(999);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
